﻿using BLL.DTO.RoleDto;
using DAL.Service;
using Helper;
using HZY.Framework.DependencyInjection;
using Model.EntityInfo;

namespace BLL.Manager
{
    public class RoleManager : IScopedSelfDependency 
    {
        private readonly RoleService _roleService;
        private readonly RouteBtRoleService _routeBtRoleService;

        public RoleManager(RoleService roleService, RouteBtRoleService routeBtRoleService)
        {
            _roleService = roleService;
            _routeBtRoleService = routeBtRoleService;
        }

        /// <summary>
        /// 获取所有角色
        /// </summary>
        /// <returns></returns>
        public Task<BaseResult<List<RoleInfoModel>>> GetAllRole()
        {
            return _roleService.getAllRole();
        }
        /// <summary>
        /// 新增角色
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<BaseResult<string>> AddRoleAsync(AddRoleDto query)
        {
            return await _roleService.AddRoleAsync(new Model.Entity.RoleEntity()
            {
                Name = query.RoleName
            }, query.RouteIds);

        }
        /// <summary>
        /// 删除角色
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<BaseResult<string>> DellRoleAsync(DellRoleDto query)
        {
            return await _roleService.DellRoleAsync(query.RoleId);

        }
        /// <summary>
        /// 更新角色
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<BaseResult<string>> UpdateRoleAsync(UpdateRoleDto query)
        {
            return await _roleService.UpdateRoleAsync(new Model.Entity.RoleEntity()
            {
                Id = query.Id,
                Name = query.RoleName
            }, query.RouteIds);

        }
    }
}
